package it.cast.wechat.dto;

import it.cast.wechat.pojo.OrderItem;
import it.cast.wechat.pojo.Product;
import it.cast.wechat.utils.CommonUtils;
import org.apache.commons.lang3.StringUtils;

public class OrderItemVo {
    private String orderItemId;

    private Integer count;

    private Double subtotal;

    private Product product;

    private String orderId;

    public String getOrderItemId() {
        return orderItemId;
    }

    public void setOrderItemId(String orderItemId) {
        this.orderItemId = orderItemId;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Double getSubtotal() {
        return subtotal;
    }

    public void setSubtotal(Double subtotal) {
        this.subtotal = subtotal;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public OrderItem builderOrderItem(){
        OrderItem orderItem = new OrderItem();
        if(StringUtils.isEmpty(this.orderItemId)){
            orderItem.setOrderItemId(CommonUtils.uuid());
        }else {
            orderItem.setOrderItemId(this.orderItemId);
        }
        orderItem.setCount(this.count);
        orderItem.setSubtotal(this.subtotal);
        orderItem.setProductId(this.product.getProductId());
        return orderItem;
    }

}
